﻿using Abp.Authorization;
using Abp.Localization;
using Abp.MultiTenancy;
using Mt.Site.Core.Authorization;
using Mt.Site.Core.Base.Authorization;

namespace Mt.Site.Core.WorkFlows.Permissions
{
    public class WorkFlowPermissionProvider : AuthorizationProvider
    {
        public override void SetPermissions(IPermissionDefinitionContext context)
        {
            var pages = context.GetPermissionOrNull(AppPermissions.Pages) ?? context.CreateMtPermission(AppPermissions.Pages, L("Pages"));

            var workFlowPManage = pages.CreateChildMtPermission(WorkFlowPermissions.Pages_Manage_WorkFlow, L("WorkFlow"), multiTenancySides: MultiTenancySides.Tenant);
            workFlowPManage.CreateChildMtPermission(WorkFlowPermissions.Pages_Manage_WorkFlow_Admin, L("Admin"), multiTenancySides: MultiTenancySides.Tenant);
            workFlowPManage.CreateChildMtPermission(WorkFlowPermissions.Pages_Manage_WorkFlow_Supervision, L("Supervision"), multiTenancySides: MultiTenancySides.Tenant);

            workFlowPManage.CreateChildMtPermission(WorkFlowPermissions.Pages_Manage_WorkFlow_ZhuanShen, L("ZhuanShen"), multiTenancySides: MultiTenancySides.Tenant);
            workFlowPManage.CreateChildMtPermission(WorkFlowPermissions.Pages_Manage_WorkFlow_GuiDang, L("GuiDang"), multiTenancySides: MultiTenancySides.Tenant);

            workFlowPManage.CreateChildMtPermission(WorkFlowPermissions.Pages_Manage_WorkFlow_GuiDang_Query, L("GuiDangQuery"), multiTenancySides: MultiTenancySides.Tenant);

        }

        private static ILocalizableString L(string name)
        {
            return new LocalizableString(name, MtSiteConsts.LocalizationSourceName_Permissions);
        }
    }
}